package br.ufrn.sigtcc.controller.cadastros;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import br.ufrn.sigtcc.controller.cadastros.interfaces.IControleLoginUsuario;
import br.ufrn.sigtcc.controller.services.LoginServiceImpl;
import br.ufrn.sigtcc.util.exceptions.BDException;
import br.ufrn.sigtcc.util.exceptions.BusinessException;

@ManagedBean(name="loginBean")
@RequestScoped
public class ControleLoginUsuario extends LoginServiceImpl implements IControleLoginUsuario{
	
	private String login;
	private String senha;
	private ControleMenuUsuario menu = new ControleMenuUsuario();
	
	public ControleLoginUsuario() {
		
	}
	
	
	

	public String getLogin() {
		return login;
	}




	public void setLogin(String login) {
		this.login = login;
	}




	public String getSenha() {
		return senha;
	}




	public void setSenha(String senha) {
		this.senha = senha;
	}




	public ControleMenuUsuario getMenu() {
		return menu;
	}


	public void setMenu(ControleMenuUsuario menu) {
		this.menu = menu;
	}

	public String login() throws BDException, BusinessException{
		
		String portal = super.login(getLogin(), getSenha());
		
		
		if(portal.equals("portalAdministrador")){
			menu.setMenu(0);
		} else if(portal.equals("portalProfessor")){
				menu.setMenu(1);
			} else if(portal.equals("portalAluno")){
					menu.setMenu(2);
				} else if(portal.equals("portalVisitante")){
						menu.setMenu(3);
			}
		
		return portal;
	}


	@Override
	public void logout() throws BDException, BusinessException {
		// TODO Auto-generated method stub
		
	}

	public String entrar() {
		// TODO Auto-generated method stub
		return "login";
	}
}
